package com.karl.mytask_2.tools;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Karl on 2016/5/27.
 */
public class ActivityCollector {

    public  static List<AppCompatActivity> activities = new ArrayList<>();

    public  static void addActivity(AppCompatActivity activity){
        activities.add(activity);
    }

    public static void removeActivity(AppCompatActivity activity){
        activities.remove(activity);
    }

    public static void finishAll(){
        for (Activity activity : activities){
            if (!activity.isFinishing()) {
                activity.finish();
            }
        }
    }
}
